package com.sg.business.commons.field.editable;

import java.util.List;

import com.mobnut.commons.util.Utils;
import com.mobnut.db.model.PrimaryObject;
import com.sg.business.model.Document;
import com.sg.widgets.part.editor.fields.value.IFieldEditableHandler;

public class DocumentTemplateFoeWorkEditable implements IFieldEditableHandler {

	@Override
	public boolean isEditable(Object data, String key, Object value) {
		if (data instanceof PrimaryObject) {
			PrimaryObject po = (PrimaryObject) data;
			Object contentVault = po.getValue(Document.F_CONTENT_VAULT);
			if (contentVault instanceof List) {
				return Utils.isNullOrEmpty((List<?>) contentVault);
			} else {
				return Utils.isNullOrEmptyString(contentVault);
			}
		}
		return true;
	}

}
